﻿using Microsoft.CodeAnalysis;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UMLSynthesizer.LangAnalyzer;
using UMLSynthesizer.LangAnalyzer.Elements;

namespace UMLSynthesizer.CSharpAnalyzer.Elements
{
    class CSharpArrayType : IArrayType
    {
        #region Fields

        IArrayTypeSymbol typeSymbol;

        #endregion

        #region Constructor

        public CSharpArrayType(CSharpProjectElement project, IArrayTypeSymbol typeSymbol)
        {
            this.ProjectOwner = project;
            this.typeSymbol = typeSymbol;

            this.MetricDictionary = new Dictionary<LanguageAnalyzer.Metrics, double>();
        }

        #endregion

        #region Properties

        public string Identifier { get { return Type.Identifier + "[]"; } }
        public ITypeBase Type { get { return (ProjectOwner as CSharpProjectElement).GetTypeReference(typeSymbol.ElementType); } }
        public ElementKinds Kind { get { return ElementKinds.ArrayType; } }

        public ITypeBase BaseType
        {
            get
            {
                ITypeBase type = Type;
                while (type as IArrayType != null)
                    type = (type as IArrayType).Type;

                return type;
            }
        }

        public IElementBase ParentElement { get; private set; }
        public IProjectElement ProjectOwner { get; private set; }

        public Dictionary<LanguageAnalyzer.Metrics, double> MetricDictionary { get; private set; }

        #endregion
    }
}
